package com.bird.pro.ctrl;


import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.bird.pro.Page;
import com.bird.pro.Params;
import com.bird.pro.pojo.BirdUser;
import com.bird.pro.service.IUserService;

@Controller
@RequestMapping("user")
public class UserController {

	@Autowired
	private IUserService userService;
	@RequestMapping("/main")
	public String main(){
		return "user/main";
	}
	
	@RequestMapping("list")
	public String list(Model model,Params params){
		Page page = userService.queryUserByMap(params);
		model.addAttribute("page", page);
		return "user/list";
	}
	
	@RequestMapping("update")
	@ResponseBody
	public String updateUser(BirdUser user){
		if (user.getId() != null) {
			user.setUserState("0");
			int result = userService.updateUser(user);
			if (result > 0) {
				return "success";
			}
		}
		return "";
	}
}
